package com.ianmoone.juc;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;

public class ExecutorTest {
	public static int a = 0;
	public static void main(String[] args) {
		ExecutorService newFixedThreadPool = Executors.newFixedThreadPool(1);
		Executors.newSingleThreadExecutor();
		ThreadPoolExecutor threadPoolExecutor = new ThreadPoolExecutor(2, 10, 60, TimeUnit.SECONDS, new ArrayBlockingQueue(10));
		for (int i = 0; i < 100; i++) {
			System.out.println("nowThreadNum+"+threadPoolExecutor.getActiveCount());
			threadPoolExecutor.execute(new Runnable() {
				@Override
				public void run() {
					System.out.println(a++);
				}
			});
		}
	}
}
